#include<bits/stdc++.h>
using namespace std;
int c[100005];
int n,m,l,v;
struct w{
    int d,v,a;
};
w car[100005];
int p[100005];
bool f[10005][10005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while (t--)
    {
        memset(car,0,sizeof(car));
        memset(p,0,sizeof(p));
        memset(f,0,sizeof(f));
        cin>>n>>m>>l>>v;
        for (int i=0;i<n;i++)
        {
            cin>>car[i].d>>car[i].v>>car[i].a;
        }
        for (int i=0;i<m;i++)
        {
            cin>>p[i];
        }
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<m;j++)
            {
                if (car[i].d>p[j])
                    f[i][j]=0;
                else
                {
                    double h=sqrt(car[i].v*car[i].v+2*car[i].a*(p[j]-car[i].d));
                    if (h<=0.0)
                        break;
                    if (h>v)
                    {
                        f[i][j]=1;
                    }
                }
            }
        }
        int s=0;
        for (int i=0;i<m;i++)
        {
            for (int j=0;j<n;j++)
            {
                if (f[j][i]==1)
                {
                    s++;
                    break;
                }
            }
        }
        cout<<s<<" 3\n";



    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}

